package com.sims.action.student;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.sims.bean.Class;
import com.sims.bean.Student;
import com.sims.service.StudentService;
import com.sims.util.ActionEnhanced;
import com.sims.util.Constant;
import com.sun.org.apache.bcel.internal.generic.NEW;

@SuppressWarnings("serial")
public class FindClassStudentAction extends ActionEnhanced{

	private String page;
	private List<Student> list = new ArrayList<Student>();
	
	@Autowired
	private StudentService studentService;

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	public List<Student> getList() {
		return list;
	}

	public void setList(List<Student> list) {
		this.list = list;
	}

	@Override
	public String execute() {
		System.out.println(page);
		result = studentService.findClassStudent(list);
		
		if (result.containsKey(Constant.SUCCESS)) {
			System.out.println("success");
			if (page.equals("score"))
				return "score";
			if (page.equals("basicInfo"))
				return "basicInfo";
			if (page.equals("eRecord"))
				return "eRecord";
			if (page.equals("attendanceRecord"))
				return "attendanceRecord";
			if (page.equals("phoneList"))
				return "phoneList";
		}
		System.out.println("error");
		return ERROR;
	}
}
